﻿using DapperExtensions;
using Nova_Common.Extend;
using Nova_DAL;
using Nova_MOD;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nova_BLL
{
    public class TUserMaterialGroupRelationBll
    {
        private readonly TUserMaterialGroupRelationDal dal = new TUserMaterialGroupRelationDal();

        public bool InsertEntity(TUserMaterialGroupRelation entity)
        {
            string id = dal.Insert(entity);
            return id.IsEmpty() ? true : false;
        }

        public bool UpdateEntity(TUserMaterialGroupRelation entity)
        {
            return dal.Update(entity);
        }

        public bool DeleteByUserNo(string userNo)
        {
            var predicate = Predicates.Field<TUserMaterialGroupRelation>(t => t.UserNo, Operator.Eq, userNo);
            return dal.Delete(predicate);
        }

        public bool DeleteEntity(TUserMaterialGroupRelation entity)
        {
            return dal.Delete(entity);
        }

        public List<TUserMaterialGroupRelation> GetList()
        {
            return dal.GetList();
        }

        public TUserMaterialGroupRelation GetByUserNo(string userNo)
        {
            var predicate = Predicates.Field<TUserMaterialGroupRelation>(t => t.UserNo, Operator.Eq, userNo);
            return dal.GetByField(predicate);
        }
    }
}
